<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>文件上传和下载</title>
</head>
<body>
<h1>九、文件上传和下载</h1>

<h2>1.文件下载</h2>
<div><a th:href="@{/a9/download?fileName=logback-test.xml&dirType=webapp}">webapp:logback-test.xml</a></div>
<div><a th:href="@{/a9/download?fileName=logback-test.xml&dirType=resource}">resource:logback-test.xml</a></div>

<h2>2.文件上传</h2>
<form th:action="@{/a9/upload}" method="post" enctype="multipart/form-data">
    <!-- input 的 name 需后端形参名字一致，或者用@RequestParam()做名字映射-->
    文件：<input type="file" name="file"><br/>
    <input type="submit" value="上传">
</form>

<h2>3.多文件上传</h2>
<form th:action="@{/a9/upload2}" method="post" enctype="multipart/form-data">
    <!-- input 的 name 需后端形参名字一致，或者用@RequestParam()做名字映射-->
    文件 ：<input type="file" name="file" accept="image/*"><br/>
    多个文件：<input type="file" name="fileArr" multiple accept="image/png,image/jpeg,text/*"><br/>
    <input type="submit" value="上传">
</form>

<h2>4.原生servlet文件上传</h2>
<form th:action="@{/a9/upload3}" method="post" enctype="multipart/form-data">
    多个文件：<input type="file" name="fileArr" multiple accept="text/*"><br/>
    <input type="submit" value="上传">
</form>

<h2>4.原生servlet文件上传，借助commons-fileupload 解析内容</h2>
<form th:action="@{/a9/upload4}" method="post" enctype="multipart/form-data">
    普通表单-地址：<input type="text" name="addr"><br/>
    单个文件 ：<input type="file" name="file" accept="image/*"><br/>
    多个文件：<input type="file" name="fileArr" multiple accept="image/*"><br/>
    <input type="submit" value="上传">
</form>

</body>
</html>